package com.sys.app.entity.token;

import cn.hutool.core.util.ObjectUtil;
import com.sys.app.entity.sys.SysAccount;

import java.util.HashMap;
import java.util.Map;

public class BaseUserInfo {
    private static ThreadLocal<SysAccount> userThreadLocal = new ThreadLocal<>();

    public static SysAccount getUser() {
        SysAccount model = userThreadLocal.get();
        if (null == model) {
            model = getTempUserModel();
        }
        return model;
    }

    public static void setUser(SysAccount userModel) {
        userThreadLocal.set(userModel);
    }
    public static void removeUser() {
        if (null != userThreadLocal && null != userThreadLocal.get()) {
            userThreadLocal.remove();
        }
    }
    private static SysAccount getTempUserModel() {
        SysAccount userModelTemp = new SysAccount();
        userModelTemp.setId(-1L);
        userModelTemp.setCode("0");
        userModelTemp.setName("游客");
        return userModelTemp;
    }
}
